package jmine.tec.test.matchers;

import java.util.concurrent.Callable;

import org.jmock.api.Invocation;
import org.jmock.lib.action.CustomAction;

/**
 * @author lundberg
 */
public class ExecuteCallableAction extends CustomAction {

    /**
     * An action that executes a callable
     * 
     * @return action
     */
    public static ExecuteCallableAction executeCallable() {
        return new ExecuteCallableAction("execute transacted");
    }

    /**
     * Constructor
     * 
     * @param description description
     */
    public ExecuteCallableAction(String description) {
        super(description);
    }

    /**
     * {@inheritDoc}
     */
    public Object invoke(Invocation invocation) throws Throwable {
        return ((Callable) invocation.getParameter(0)).call();
    }

}
